﻿Module Module1
    Function Bai12(ByVal x As Double, ByVal n As Integer) As Double
        Dim T As Integer = 1
        Dim S As Integer = 0
        Dim i As Integer
        For i = 1 To n Step 1
            T = x ^ i
            S = S + T
        Next
        Return S
    End Function
    Sub Main()
        Dim n, x As Integer
        Console.WriteLine("Nhap so x: ")
        x = Console.ReadLine()
        Console.WriteLine("Nhap so n: ")
        n = Console.ReadLine()
        Dim kq As Double
        kq = Bai12(x, n)
        Console.WriteLine("S(n)= " & kq)
    End Sub
End Module
